#include <bits/stdc++.h>
#define ints long long
using namespace std;
ints T,n,ans,A[100001];
bool g[100001];//false=blue true=red
void dfs(ints x,ints c){
    ints next=c;
    if(x>n){
        ans=max(ans,next);
        return;
    }
    for(ints i=x-1;i>=0;i--)
        if(g[i]==g[x]&&A[i]==A[x]){
            next+=A[i];
            break;
        }
    g[x]=true;
    dfs(x+1,next);
    g[x]=false;
    dfs(x+1,next);
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        ans=0;
        memset(A,0,sizeof A);
        memset(g,false,sizeof g);
        scanf("%d",&n);
        for(ints i=0;i<n;i++)scanf("%d",&A[i]);
        dfs(0,0);
        printf("%d\n",ans);
    }
    return 0;
}
